<%@ Page Title="Charities" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" AutoEventWireup="true" 
	Inherits="System.Web.Mvc.ViewPage<IEnumerable<good1.Core.Charity>>" %>
<%@ Import Namespace="good1.Core" %>
<%@ Import Namespace="good1.Web.Controllers" %>

<asp:Content ContentPlaceHolderID="mainContentPlaceHolder" runat="server">
    <h2>Charities</h2>

    <% if (ViewContext.TempData["message"] != null){ %>
        <p><%= ViewContext.TempData["message"]%></p>
    <% } %>

    <table>
        <thead>
            <tr>
			    <th>CharityName</th>
			    <th>Url</th>
			    <th>Description</th>
			    <th>TagLine</th>
			    <th colspan="3">Action</th>
            </tr>
        </thead>

		<%
		foreach (Charity charity in ViewData.Model) { %>
			<tr>
				<td><%= charity.CharityName %></td>
				<td><%= charity.Url %></td>
				<td><%= charity.Description %></td>
				<td><%= charity.TagLine %></td>
				<td><%=Html.ActionLink<CharitiesController>( c => c.Show( charity.Id ), "Details ") %></td>
				<td><%=Html.ActionLink<CharitiesController>( c => c.Edit( charity.Id ), "Edit") %></td>
				<td>
    				<% using (Html.BeginForm<CharitiesController>(c => c.Delete(charity.Id))) { %>
                        <%= Html.AntiForgeryToken() %>
    				    <input type="submit" value="Delete" onclick="return confirm('Are you sure?');" />
                    <% } %>
				</td>
			</tr>
		<%} %>
    </table>

    <p><%= Html.ActionLink<CharitiesController>(c => c.Create(), "Create New Charity") %></p>
</asp:Content>
